﻿using System;

namespace BoldBrick.OneIntranet.HR.FieldTypes
{
	/// <summary>
	/// Value for <see cref="ContentTypeLookup"/> field
	/// </summary>
	public class ListLookupValue
	{
		/// <summary>
		/// Content type ID
		/// </summary>
		public Guid ListID { get; private set; }

		/// <summary>
		/// Content type name
		/// </summary>
		public string ListName { get; private set; }

		public ListLookupValue(Guid listId, string listName)
		{
			this.ListID = listId;
			this.ListName = listName;
		}

		public ListLookupValue(string value)
		{
			string[] values = value.Split(';');
			if (values.Length != 2)
				throw new ArgumentException("Value has to in <something>;#<something> format.", value);

			this.ListID = new Guid(values[0]);
			this.ListName = values[1];
		}

		public override string ToString()
		{
			return string.Format("{0};{1}", this.ListID, this.ListName);
		}
	}
}
